<?php
/* -----------------------------------------------------------------------------------------
   $Id: specials.php,v 1.1 2010/09/08 11:00:23 akausch Exp $   

   XT-Commerce - community made shopping
   http://www.xt-commerce.com

   Copyright (c) 2003 XT-Commerce
   -----------------------------------------------------------------------------------------
   based on: 
   (c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
   (c) 2002-2003 osCommerce(specials.php,v 1.47 2003/05/27); www.oscommerce.com 
   (c) 2003	 nextcommerce (specials.php,v 1.12 2003/08/17); www.nextcommerce.org

   Released under the GNU General Public License 
   ---------------------------------------------------------------------------------------*/

include ('includes/application_top.php');
$smarty = new Smarty;

if ($mobile_template == 'False') {
	require (DIR_FS_CATALOG.'templates/'.CURRENT_TEMPLATE.'/source/boxes.php');
} else {
	require (DIR_FS_CATALOG.'templates/'.CURRENT_MOBILE_TEMPLATE.'/source/boxes.php');
}
require_once (DIR_FS_INC.'xtc_get_short_description.inc.php');

$breadcrumb->add(NAVBAR_TITLE_SPECIALS, xtc_href_link(FILENAME_SPECIALS));

if ($_SESSION['customers_status']['customers_fsk18_display'] == '0')
	$fsk_lock = ' AND p.products_fsk18 != 1';
	
if (GROUP_CHECK == 'true')
	$group_check = " AND p.group_permission_".$_SESSION['customers_status']['customers_status_id']." = 1 ";
	
$specials_query_raw = "SELECT 
						p.products_id,
                        pd.products_name,
						pd.products_short_description,
						pd.products_description,
                        p.products_price,
                        p.products_tax_class_id,
						p.products_shippingtime,
                        p.products_image,
						p.products_vpe_status,
						p.products_vpe_value,
						p.products_vpe,
						p.products_fsk18,
                        s.specials_new_products_price 
					FROM 
						".TABLE_PRODUCTS." p, 
						".TABLE_PRODUCTS_DESCRIPTION." pd, 
						".TABLE_SPECIALS." s
                    WHERE 
						p.products_status = '1'
                    AND 
						s.products_id = p.products_id
                    AND 
						p.products_id = pd.products_id
                        ".$group_check."
                        ".$fsk_lock."
                    AND 
						pd.language_id = '".(int) $_SESSION['languages_id']."'
                    AND 
						s.status = '1' 
					ORDER BY 
						s.specials_date_added DESC";
						
$specials_split = new splitPageResults($specials_query_raw, $_GET['page'], MAX_DISPLAY_SPECIAL_PRODUCTS);
if (($specials_split->number_of_rows > 0)) {
	$navigation_smarty = new Smarty;
	$page_links = $specials_split->getLinksArray(MAX_DISPLAY_PAGE_LINKS,xtc_get_all_get_params(array('page', 'info', 'x', 'y')),TEXT_DISPLAY_NUMBER_OF_PRODUCTS);
	$navigation_smarty -> assign('LINKS', $page_links);
	$navigation_smarty -> assign('language', $_SESSION['language']);
	if ($mobile_template == 'False') {
		$navigation_smarty -> assign('tpl_path', 'templates/'.CURRENT_TEMPLATE.'/');
		$navigation = $navigation_smarty -> fetch(CURRENT_TEMPLATE.'/module/products_page_navigation.html');
	} else {
		$navigation_smarty -> assign('tpl_path', 'templates/'.CURRENT_MOBILE_TEMPLATE.'/');
		$navigation = $navigation_smarty -> fetch(CURRENT_MOBILE_TEMPLATE.'/module/products_page_navigation.html');
	}

}
#$module_content = '';
$module_content = array ();
$row = 0;
if ($specials_split->number_of_rows==0) 
	xtc_redirect(xtc_href_link(FILENAME_DEFAULT));
	
require (DIR_WS_INCLUDES.'header.php');
$specials_query = xtc_db_query($specials_split->sql_query);
$i=0;
while ($specials = xtc_db_fetch_array($specials_query)) { $i++;
	$module_content[] = $product->buildDataArray($specials, 'thumbnail', 'specials', $i);
}

$smarty->assign('language', $_SESSION['language']);
$smarty->assign('module_content', $module_content);
$smarty->assign('TITLE', SPECIALS);
$smarty->caching = 0;
if ($mobile_template == 'False') {
	$main_content = $smarty->fetch(CURRENT_TEMPLATE.'/module/product_listings.html');
} else {
	$main_content = $smarty->fetch(CURRENT_MOBILE_TEMPLATE.'/module/product_listings.html');
}

$smarty->assign('language', $_SESSION['language']);
$smarty->assign('main_content', $main_content);
$smarty->caching = 0;
if (!defined(RM))
	$smarty->load_filter('output', 'note');
if ($mobile_template == 'False') {
	$smarty->display(CURRENT_TEMPLATE.'/index.html');
} else {
	$smarty->display(CURRENT_MOBILE_TEMPLATE.'/index.html');
}

include ('includes/application_bottom.php');
?>